package com.westos.echufang.controller;

import com.westos.echufang.pojo.entity.Employee;
import com.westos.echufang.service.admin.AdminService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class delController {
    @Autowired
    AdminService adminService;

    @RequestMapping("/emp/del")
    public String delEmpByAdmin(@Param("id") int id, HttpServletRequest request, HttpServletResponse response){
        int i = adminService.delEmp(id);
        if(i>0){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
//        List<Employee> emps = adminService.Emps();
//        model.addAttribute("list",emps);
        try {
            request.getRequestDispatcher("/query/all").forward(request,response);
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "null";
    }
}
